/**
 * <p>
 * </p>
 *
 * @author zhuolin
 * @since 2020/5/27
 */
public class InterruptThread {
    static int i = 0;
    public static void main(String[] args) throws InterruptedException {

        Thread t = new Thread(() -> {
            while(true){
                System.out.println(i++);
                if(Thread.currentThread().isInterrupted()){
                    System.out.println("interrupt");
                    break;
                }
                Thread.yield();
            }
        });
        t.start();
        Thread.sleep(2000);
        System.out.println("==");
        t.interrupt();
    }
}
